//
//  HotSecondCell.m
//  HomePage
//
//  Created by dlios on 15-1-28.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HotSecondCell.h"
#import "UIImageView+WebCache.h"
@implementation HotSecondCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.labelTitle = [[UILabel alloc]init];
        self.imageViewBack = [[UIImageView alloc] init];
        self.imageViewPhoto = [[UIImageView alloc] init];
        self.labelPlaysCounts = [[UILabel alloc] init];
        self.labelTracksCounts = [[UILabel alloc] init];
        self.bofangTubiao = [[UIImageView alloc] init];
        self.imageViewBack.userInteractionEnabled = YES;
        self.imageViewPhoto.userInteractionEnabled = YES;
        

       
    }
    return self;
}
//- (void)setSecondHot:(HotSecond *)SecondHot
//{
//    if (_SecondHot != SecondHot) {
//        [_SecondHot release];
//        _SecondHot = [SecondHot retain];
//        self.labelTitle.text = self.SecondHot.title;
//        NSString *str = self.SecondHot.albumCoverUrl290;
//        NSURL *url  = [NSURL URLWithString:str];
//        [self.imageViewPhoto setImageWithURL:url];
//    }
//}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.contentView.backgroundColor = [UIColor colorWithRed:225/255.0 green:237/255.0 blue:238/255.0 alpha:1];
    self.imageViewBack.frame = CGRectMake(self.contentView.frame.size.width / 75, self.contentView.frame.size.height / 21.2, self.contentView.frame.size.width, self.contentView.frame.size.height / 1.11);
    self.imageViewBack.image = [UIImage imageNamed:@"white.png"];
    [self.contentView addSubview:self.imageViewBack];
    self.labelTitle.frame = CGRectMake(self.contentView.frame.size.width / 3.56, 0, self.imageViewBack.frame.size.width / 1.39, self.contentView.frame.size.height / 1.67);
    self.labelTitle.textAlignment = NSTextAlignmentLeft;
    self.labelTitle.numberOfLines = 0;
    //self.labelTitle.backgroundColor = [UIColor blueColor];
       self.shareButton.frame = CGRectMake(self.contentView.frame.size.width / 1.25, self.contentView.frame.size.height / 2.117, 60, 30);
    self.labelTitle.text = self.SecondHot.title;
    [self.imageViewBack addSubview:self.labelTitle];
    self.labelPlaysCounts.frame = CGRectMake(self.contentView.frame.size.width / 2.8, self.contentView.frame.size.height / 2.117, self.contentView.frame.size.width / 5.5, self.contentView.frame.size.height / 3.53);
   // self.labelPlaysCounts.backgroundColor = [UIColor redColor];
    self.labelPlaysCounts.font = [UIFont systemFontOfSize:14];
    self.labelPlaysCounts.textColor = [UIColor colorWithRed:216 / 255 green:216 / 255 blue:221 / 255 alpha:1];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    NSString *strPlaysCounts = [numberFormatter stringFromNumber:self.SecondHot.playsCounts];
    float jisuan = [strPlaysCounts floatValue];
    float jieguo = jisuan / 10000;
    NSString *Finally = [NSString stringWithFormat:@"%0.1f",jieguo];
    NSString *strFinally = [Finally stringByAppendingString:@"万"];
    self.labelPlaysCounts.text = strFinally;
    self.labelPlaysCounts.alpha = 0.8;
    [self.imageViewBack addSubview:self.labelPlaysCounts];
    self.bofangTubiao.frame = CGRectMake(self.contentView.frame.size.width / 3.56, self.contentView.frame.size.height / 1.87, self.contentView.frame.size.width / 18.75, self.contentView.frame.size.height / 5.294);
    [self.bofangTubiao setImage:[UIImage imageNamed:@"secondbofang1.png"]];
    [self.imageViewBack addSubview:self.bofangTubiao];
    self.imageViewPhoto.frame = CGRectMake(0, 0, self.imageViewBack.frame.size.width / 4, self.imageViewBack.frame.size.height);
    NSString *str = self.SecondHot.albumCoverUrl290;
    NSURL *url  = [NSURL URLWithString:str];
    [self.imageViewPhoto setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
    [self.imageViewBack addSubview:self.imageViewPhoto];
}
@end
